# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/items.html

import scrapy


class TaoboLiveItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    accountId = scrapy.Field()
    accountNick = scrapy.Field()
    headImg = scrapy.Field()
    topic = scrapy.Field()
    fansNum = scrapy.Field()
    roomNum = scrapy.Field()
    title = scrapy.Field()
    account_url = scrapy.Field()

    def save_to_mysql(self):

        sql = 'insert into tblive2(accountId,accountNick,headImg,topic,fansNum,roomNum,title,account_url)' \
              'values (%s,%s,%s,%s,%s,%s,%s,%s)'


        data = (self["accountId"],self["accountNick"],self["headImg"],self["topic"],self["fansNum"],self["roomNum"],self["title"],self["account_url"])

        return sql,data
